package p270jp.pxv.android.comment.presentation.view;

import android.annotation.SuppressLint;
import android.content.Context;
import android.util.AttributeSet;
import android.view.KeyEvent;
import android.view.LayoutInflater;
import android.view.MotionEvent;
import android.view.View;
import android.view.inputmethod.InputMethodManager;
import android.widget.EditText;
import android.widget.ImageView;
import android.widget.TextView;
import androidx.constraintlayout.widget.ConstraintLayout;
import androidx.constraintlayout.widget.ConstraintSet;
import java.util.Objects;
import p014ae.View$OnClickListenerC0151s;
import p014ae.View$OnClickListenerC0158t;
import p062c4.ViewBindings;
import p105df.ViewCommentInputBinding;
import p270jp.pxv.android.R;
import p270jp.pxv.android.comment.presentation.view.CommentInputView;
import p325m0.MutabilityOwnership;

/* compiled from: CommentInputView.kt */
/* renamed from: jp.pxv.android.comment.presentation.view.CommentInputView */
/* loaded from: classes2.dex */
public final class CommentInputView extends ConstraintLayout {

    /* renamed from: A */
    public static final /* synthetic */ int f18950A;

    /* renamed from: s */
    public final ViewCommentInputBinding f18951s;

    /* renamed from: t */
    public final ConstraintSet f18952t;

    /* renamed from: u */
    public final ConstraintSet f18953u;

    /* renamed from: v */
    public boolean f18954v;

    /* renamed from: w */
    public boolean f18955w;

    /* renamed from: x */
    public boolean f18956x;

    /* renamed from: y */
    public boolean f18957y;

    /* renamed from: z */
    public AbstractC4207a f18958z;

    /* compiled from: CommentInputView.kt */
    /* renamed from: jp.pxv.android.comment.presentation.view.CommentInputView$a */
    /* loaded from: classes2.dex */
    public interface AbstractC4207a {
        /* renamed from: a */
        void mo3823a();

        /* renamed from: b */
        void mo3822b();

        /* renamed from: c */
        void mo3821c();

        /* renamed from: d */
        void mo3820d(String str);
    }

    /* JADX WARN: 'super' call moved to the top of the method (can break code semantics) */
    public CommentInputView(Context context, AttributeSet attributeSet) {
        super(context, attributeSet);
        MutabilityOwnership.m3745m(context, "context");
        LayoutInflater.from(getContext()).inflate(R.layout.view_comment_input, this);
        int i = R.id.button_comment_send;
        ImageView imageView = (ImageView) ViewBindings.m9835b(this, R.id.button_comment_send);
        if (imageView != null) {
            i = R.id.button_emoji_toggle;
            ImageView imageView2 = (ImageView) ViewBindings.m9835b(this, R.id.button_emoji_toggle);
            if (imageView2 != null) {
                i = R.id.comment_edit_text;
                EditText editText = (EditText) ViewBindings.m9835b(this, R.id.comment_edit_text);
                if (editText != null) {
                    i = R.id.text_counter;
                    TextView textView = (TextView) ViewBindings.m9835b(this, R.id.text_counter);
                    if (textView != null) {
                        this.f18951s = new ViewCommentInputBinding(this, imageView, imageView2, editText, textView, 0);
                        ConstraintSet bVar = new ConstraintSet();
                        bVar.m11474c(this);
                        this.f18952t = bVar;
                        imageView.setEnabled(false);
                        imageView2.setOnClickListener(new View$OnClickListenerC0158t(this, 11));
                        imageView.setOnClickListener(new View$OnClickListenerC0151s(this, 7));
                        editText.addTextChangedListener(new p340mf.CommentInputView(this));
                        editText.setOnFocusChangeListener(new View.OnFocusChangeListener() { // from class: mf.a
                            @Override // android.view.View.OnFocusChangeListener
                            public final void onFocusChange(View view, boolean z) {
                                CommentInputView commentInputView = CommentInputView.this;
                                int i2 = CommentInputView.f18950A;
                                MutabilityOwnership.m3745m(commentInputView, "this$0");
                                MutabilityOwnership.m3745m(view, "$noName_0");
                                if (z) {
                                    commentInputView.m4623t();
                                    CommentInputView.AbstractC4207a aVar = commentInputView.f18958z;
                                    if (aVar != null) {
                                        aVar.mo3822b();
                                    }
                                }
                            }
                        });
                        m4621v(0);
                        ConstraintSet bVar2 = new ConstraintSet();
                        bVar2.m11474c(this);
                        bVar2.m11473d(imageView2.getId(), 4, 0, 4);
                        bVar2.m11473d(imageView2.getId(), 1, 0, 1);
                        bVar2.m11473d(imageView2.getId(), 2, textView.getId(), 1);
                        bVar2.m11473d(imageView2.getId(), 3, editText.getId(), 4);
                        bVar2.m11470g(imageView2.getId()).f2418d.f2457W = 1;
                        int id = editText.getId();
                        int id2 = imageView2.getId();
                        if (!bVar2.f2414c.containsKey(Integer.valueOf(id))) {
                            bVar2.f2414c.put(Integer.valueOf(id), new ConstraintSet.C0557a());
                        }
                        ConstraintSet.C0557a aVar = bVar2.f2414c.get(Integer.valueOf(id));
                        if (aVar != null) {
                            ConstraintSet.C0559b bVar3 = aVar.f2418d;
                            bVar3.f2489o = id2;
                            bVar3.f2491p = -1;
                            bVar3.f2493q = -1;
                            bVar3.f2494r = -1;
                            bVar3.f2495s = -1;
                            bVar3.f2444J = 0;
                        }
                        bVar2.m11473d(editText.getId(), 1, 0, 1);
                        bVar2.m11473d(editText.getId(), 2, 0, 2);
                        bVar2.m11473d(editText.getId(), 3, 0, 3);
                        bVar2.m11473d(textView.getId(), 4, imageView.getId(), 4);
                        bVar2.m11473d(textView.getId(), 1, imageView2.getId(), 2);
                        bVar2.m11473d(textView.getId(), 2, imageView.getId(), 1);
                        bVar2.m11473d(textView.getId(), 3, imageView.getId(), 3);
                        bVar2.m11473d(imageView.getId(), 4, imageView2.getId(), 4);
                        bVar2.m11473d(imageView.getId(), 1, textView.getId(), 2);
                        bVar2.m11473d(imageView.getId(), 2, 0, 2);
                        bVar2.m11473d(imageView.getId(), 3, imageView2.getId(), 3);
                        this.f18953u = bVar2;
                        return;
                    }
                }
            }
        }
        throw new NullPointerException("Missing required view with ID: ".concat(getResources().getResourceName(i)));
    }

    @Override // android.view.ViewGroup, android.view.View
    public boolean dispatchKeyEventPreIme(KeyEvent keyEvent) {
        MutabilityOwnership.m3745m(keyEvent, "event");
        if (keyEvent.getAction() != 0 || !this.f18957y) {
            return super.dispatchKeyEventPreIme(keyEvent);
        }
        AbstractC4207a aVar = this.f18958z;
        if (aVar == null) {
            return true;
        }
        aVar.mo3823a();
        return true;
    }

    @Override // android.view.ViewGroup
    public boolean onInterceptTouchEvent(MotionEvent motionEvent) {
        MutabilityOwnership.m3745m(motionEvent, "event");
        return this.f18956x;
    }

    /* renamed from: s */
    public final void m4624s(boolean z) {
        if (!this.f18954v) {
            m4623t();
        }
        if (z) {
            ((EditText) this.f18951s.f12244e).clearFocus();
            ((ImageView) this.f18951s.f12243d).setImageResource(R.drawable.ic_emoji_blue);
            return;
        }
        ((ImageView) this.f18951s.f12243d).setImageResource(R.drawable.ic_emoji);
    }

    public final void setCallback(AbstractC4207a aVar) {
        MutabilityOwnership.m3745m(aVar, "callback");
        this.f18958z = aVar;
    }

    public final void setReplyMode(boolean z) {
        this.f18955w = z;
    }

    /* renamed from: t */
    public final void m4623t() {
        if (!this.f18954v) {
            this.f18954v = true;
            this.f18953u.m11475b(this, true);
            setConstraintSet(null);
            requestLayout();
            ((TextView) this.f18951s.f12245f).setVisibility(0);
        }
    }

    /* renamed from: u */
    public final void m4622u() {
        Object systemService = getContext().getSystemService("input_method");
        Objects.requireNonNull(systemService, "null cannot be cast to non-null type android.view.inputmethod.InputMethodManager");
        ((InputMethodManager) systemService).hideSoftInputFromWindow(((EditText) this.f18951s.f12244e).getWindowToken(), 0);
        this.f18957y = false;
    }

    @SuppressLint({"SetTextI18n"})
    /* renamed from: v */
    public final void m4621v(int i) {
        ((TextView) this.f18951s.f12245f).setText(i + "/140");
    }
}
